<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.min.js"></script>
    <style>
        ul{
            list-style: none;
        }
        .nav li{
            display: inline-block;
            padding: 20px 40px;
            cursor: pointer;
        }
        .nav li.active{
            color: red;
        }
        .tab .main{
            display: none;
        }
        .tab .main.active{
            display: block;
        }
    </style>
</head>
<body>
    <div id="app">
       <div class="tab">
            <ul class="nav">
                <li @click="index=0" :class="{active:index==0}">水果</li>
                <li @click="index=1" :class="{active:index==1}">动物</li>
            </ul>
            <ul class="main" :class="{active:index==0}">
                <li>橘子</li>
                <li>葡萄</li>
                <li>苹果</li>
            </ul>
            <ul class="main" :class="{active:index==1}">
                <li>猪八戒</li>
                <li>鳄鱼</li>
                <li>大象</li>
            </ul>
       </div>
    </div>
    <script>
        const app = new Vue({
            el:"#app",
            data:{
                //记录活跃tab索引
                index:0
            }
        })
    </script>
</body>
</html>